<?php
registerTable("table_application_nodelocalinfo", new table_application_nodelocalinfo());

class table_application_nodelocalinfo extends Database
{
    public function __construct()
    {
        parent::__construct("nodelocalinfo");
    }

    public function pushData($location, $requestname, $data)
    {
        if ($this->contains($location, $requestname)) {
            parent::update(array("data" => $data), "`location`=$location AND `requestname`='$requestname'");
            return;
        }
        parent::insert(array("data" => $data, "location" => $location, "requestname" => $requestname), array("location"));
    }

    public function contains($location, $requestname)
    {
        return $this->count_something("`location`=$location AND `requestname`='$requestname'") == 1;
    }

    public function fetch_by_location_and_requestname($requestname, $location)
    {
        return $this->fetch_assoc("`location`=$location AND `requestname`='$requestname'");
    }
}
